﻿package  
{
	import Common.RenderManager;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import ui.AlartUIHandler;
	import ui.BattleResultUIHandler;
	import ui.ChatUIHandler;
	import ui.ItemUIHandler;
	import ui.MailUIHandler;
	import ui.MainUIHandler;
	import ui.MapUIHandler;
	import ui.NpcTalkUIHandler;
	import ui.PetInfoUIHandler;
	import ui.PetUIHandler;
	import ui.PhotoUIHandler;
	import ui.RoleInfoUIHandler;
	import ui.TeamUIHandler;
	
	
	/**
	 * ...
	 * @author fox
	 */
	public class GameUIManager 
	{
		public var bottomSprite:Sprite = null;
		public var level1Sprite:Sprite = null;
		
		public var uiArray:Array = null;
		public var bottomArray:Array = null;
		public var level1Array:Array = null;
		
		
		public function GameUIManager() 
		{
			
		}
		
		
		public function init():void
		{
			uiArray = new Array();
			
			bottomSprite = new Sprite();
			bottomSprite.mouseEnabled = false;
			
			level1Sprite = new Sprite();
			level1Sprite.mouseEnabled = false;
			
			RenderManager.instance.UISprite.addChild( bottomSprite );
			RenderManager.instance.UISprite.addChild( level1Sprite );
			
			
			uiArray.push( RoleInfoUIHandler.Instance() );
			uiArray.push( ChatUIHandler.Instance() );
			uiArray.push( MainUIHandler.Instance() );
			uiArray.push( MainUIHandler.Instance() );
			uiArray.push( ItemUIHandler.Instance() );
			uiArray.push( ItemUIHandler.Instance() );
			uiArray.push( PetUIHandler.Instance() );
			uiArray.push( PetInfoUIHandler.Instance() );
			uiArray.push( MailUIHandler.Instance() );
			uiArray.push( PhotoUIHandler.Instance() );
			uiArray.push( NpcTalkUIHandler.Instance() );
			uiArray.push( BattleResultUIHandler.Instance() );
			uiArray.push( TeamUIHandler.Instance() );
			uiArray.push( AlartUIHandler.Instance() );
			uiArray.push( MapUIHandler.Instance() );
			
			
			
			ChatUIHandler.instance.visible( true );
			MainUIHandler.instance.visible( true );
			BattleResultUIHandler.instance.visible( true );
			NpcTalkUIHandler.instance.visible( true );
		}
		
		
		public function resize():void
		{
			for ( var i:int = 0 ; i < uiArray.length ; i++ )
			{
				uiArray[ i ].resize();
			}
		}
		
		
		public function addLevel1UI( ui:Object ):void
		{
			level1Sprite.addChild( ui as DisplayObject );
			
		}
		
		
		public function addBottomUI( ui:Object ):void
		{
			bottomSprite.addChild( ui as DisplayObject );
			
		}
		
		
		public function update( delay:Number ):void
		{
			for ( var i:int = 0 ; i < uiArray.length ; i++ )
			{
				uiArray[ i ].update( delay );
			}
		}
		
		
		public function release():void
		{
			
		}
		
		
		public static var instance:GameUIManager = null;
		public static function Instance():GameUIManager
		{
			if ( instance == null )
			{
				instance = new GameUIManager();
			}
			
			return instance;
		}
		
	}
	
}